/*
 * Copyright © 2022
 * @Author: zhangxiang
 * @Date: 2022-11-24 11:00:12
 * @LastEditors: zhangxiang
 * @LastEditTime: 2022-11-24 11:12:03
 * @Description:
 *
 */

import store from '@/store'

export default {
  data() {
    return {
      menuKey: this.$route.meta ? this.$route.meta.menuKey : ''
    }
  },
  computed: {
    /**
     * @description: 页面权限
     * @return {*}
     */
    pagePermission() {
      const pagePermissions = store.getters.pagePermissions
      if (Object.keys(pagePermissions).includes(this.menuKey)) {
        return pagePermissions[this.menuKey]
      }
      return []
    },
    /**
     * @description: 是否有创建权限
     * @return {*}
     */
    hasPermissionCreate() {
      return this.pagePermission.includes('create')
    },
    /**
     * @description: 是否有删除权限
     * @return {*}
     */
    hasPermissionDelete() {
      return this.pagePermission.includes('delete')
    },
    /**
     * @description: 是否有浏览权限
     * @return {*}
     */
    hasPermissionBrowse() {
      return this.pagePermission.includes('browse')
    },
    /**
     * @description: 是否有使用权限
     * @return {*}
     */
    hasPermissionUse() {
      return this.pagePermission.includes('use')
    }
  }
}
